# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from time import sleep
"""
在执行这个用例之前，你要确保：
1、你的设备是开启的状态
2、你是用adb连接了设备才可以

"""

caps = {}
caps["appPackage"] = "me.onehome.app"
caps["appActivity"] = ".activity.ActivitySplash_"
caps["platformVersion"] = "7.1.2"
caps["platformName"] = "Android"
caps["deviceName"] = "d2q"

driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
driver.implicitly_wait(15)

# el1 = driver.find_element_by_id("me.onehome.app:id/tv_agree") #这是以前的写法，现在不支持了
# el1.click()

el1 = driver.find_element(MobileBy.ID,"me.onehome.app:id/tv_agree")
el1.click()
sleep(2)
TouchAction(driver).press(x=695, y=847).move_to(x=46, y=849).release().perform()
sleep(2)
TouchAction(driver).tap(x=161, y=1156).perform()
